////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                           BailterRay                                       //
//                    Pip Robbins & Zhao Zhang                                //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
class BailterRayKey extends UTCTFBlueFlag;

var rotator KeyHomeRotation;
var rotator KeyHeldRotation;
var ParticleSystem ParticleEffectsGlow;
var ParticleSystemComponent BaseGlow;
var vector BaseGlowOffset;
var float RespawnEffectTime;

simulated function PostBeginPlay()
{
    BaseGlow = WorldInfo.MyEmitterPool.SpawnEmitter(ParticleEffectsGlow, Location + BaseGlowOffset);
    BaseGlow.SetScale(1.8);
    BaseGlow.SetActive(true);
    Super.PostBeginPlay();

}

function SetHolder(Controller C)
{
   super.SetHolder(C);
   if(BaseGlow != none)
       BaseGlow.DeactivateSystem();
}

state Held
{
    simulated function Tick(float DeltaTime)
    {
        // Rotates the key when held
        KeyHeldRotation.Pitch += 4600 * DeltaTime;
        SkelMesh.SetRotation(KeyHeldRotation);
        SkelMesh.SetScale(1.4);
    }

}

auto state Home
{
     simulated function Tick(float DeltaTime)
    {
        // Rotates the key when held
        KeyHomeRotation.Roll = 16384;
        KeyHomeRotation.Yaw += 8200 * DeltaTime;
        SkelMesh.SetRotation(KeyHomeRotation);
        SkelMesh.SetScale(2.4);

        RespawnEffectTime += DeltaTime;
        if(RespawnEffectTime >= 3)
        {
            BaseGlow.DeactivateSystem();
            BaseGlow = WorldInfo.MyEmitterPool.SpawnEmitter(ParticleEffectsGlow, Location + BaseGlowOffset);
            BaseGlow.SetScale(2.2);
            BaseGlow.SetActive(true);
            RespawnEffectTime = 0;
        }
    }

}
defaultproperties
{
   Begin Object name=TheFlagSkelMesh
      SkeletalMesh=SkeletalMesh'BailterRayAssetPackage.Meshes.ShipKey'
      Scale = 1.4;
      Rotation = (Pitch=0,Yaw=16384,Roll=16384)
   End Object
   SkelMesh=TheFlagSkelMesh

   Begin Object Name=FlagLightComponent
      LightColor=(B=65,G=65,R=65,A=255)

   End Object

   // Changes the position and rotation when held
   GameObjOffset3P=(X=0,Y=32,Z=0)
   GameObjRot3P=(Pitch=0,Yaw=32768,Roll=0)

   ParticleEffectsGlow=ParticleSystem'BailterRay_RayGun.Effects.Spawn_Effect'
   BaseGlowOffset = (X=0 ,Y=0, Z=-30)

   PickupSound=SoundCue'BailterRaySoundPackages.BR_Sci_fi_youfoudthekey'
   DroppedSound=none
   ReturnedSound=none

   MessageClass=class'BailterRay.BailterRayMessage'

}

